import 'dart:convert';

import 'package:flutter/material.dart';

import '../../data/menu_data.dart';
import '../../model/listview_model.dart';
import '../../routes/fluro/application.dart';

class MenuListPage extends StatefulWidget {

  const MenuListPage({Key? key}) : super(key: key);

  @override
  State<MenuListPage> createState() => _MenuListPageState();
}
class _MenuListPageState extends State<MenuListPage> {

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {

    List<ListViewModel> menuList = List<ListViewModel>.from(
        menuListData.map((item) => ListViewModel.fromJson(item)).toList());

    return ListView.builder(
      // itemCount:指定该数组的长度
      itemCount: menuList.length,
      //itemBuilder 会进行循环遍历
      itemBuilder: (contText, index) {
        return ListTile(
          title: Text(menuList[index].title),
          subtitle: Text(menuList[index].msgContent),
          onTap: (){
            print(menuList[index].path);
            Application.router.navigateTo(context,menuList[index].path);
            //Navigator.of(context).popUntil(ModalRoute.withName(menuList[index].path));
          },
        );
      },
    );
  }
}
